package problems;

import org.junit.Test;

import java.util.HashSet;
import java.util.Set;

/**
 * Created with IntelliJ IDEA.
 * User: Vikas.Bhardwaj
 * Date: 5/23/12
 * Time: 3:03 PM
 * To change this template use File | Settings | File Templates.
 */
public class tests {

    @Test
    public void runSqrt(){
        BinarySearchProblems.findSqrt(199999999);
    }

    @Test
    public void testMatrixSearch(){
        int[][] A = new int[3][];

        A[0] = new int[]{1, 5 , 8 ,10};
        A[1] = new int[]{3, 6 , 11 ,12};
        A[2] = new int[]{8, 15, 19 ,28};

        BinarySearchProblems.matrixSearch(A,10);

    }

    @Test
    public void testMaxSum(){
        int[] A = new int[] { -1, 8 , -5, 6, 10 ,13,2,-3,6 , 9 };

        DynamicProgramming.maxSumSubArray(A);
    }

    @Test
    public void testLongestNDSubSeq(){
        int[] A = new int[] {6,7,8, 1,10,2,3, 11,14,6,15,16,17};
        DynamicProgramming.longestNonDecreasingSubSequence(A);
    }

    @Test
    public void validWordsTest(){
        Set<String> words = new HashSet<String>(){{
            add("bed");
            add("bat");
            add("had");
            add("and");
            add("hand");
            add("bath");
            add("beyond");
        }};

        String s = "bedbathandbeyond";

        DynamicProgramming.validWords(words,s);

    }

    @Test
    public void testTiePossibility(){

        Integer[] numOfElectors = new Integer[]{ 15 , 34 , 10 ,4 ,5};

        DynamicProgramming.tiePossibility(numOfElectors);
    }
}
